<?php
namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class PositionsController extends AdminbaseController {
		
	// 广告列表
	public function index() {
		$Positions=D('Positions');

		$list=$Positions->get();

		$this->assign('list',$list);
		$this->display();
	}

	//	添加广告位
	public function add() {
		$this->display();
	}

	//	添加广告位
	public function edit($id=0) {
		$vo=M('Positions')->where("id=$id")->find();
		$this->assign('vo',$vo);
		$this->display();
	}


	public function add_post() {
		$data=I('post.');
		$data['positionFlag']=0;
		if(M('Positions')->add($data)) $this->success("广告添加成功", U("Positions/index"));
		else  $this->error('广告添加失败');
	}

	// 删除广告位
	public function delete($id=0){

  		$Positions=M('Positions');

  		if($id) $re=$Positions->save(['positionFlag'=>1,'id'=>$id]);
  		else $this->error('数据传入失败！');

  		if($re) $this->success("广告位删除成功", U("Positions/index"));
  		else $this->error('广告位删除失败！');

	}

	

}